﻿using System;
using System.Windows;
using Dsl.Ped.Common.Helpers;

namespace Dsl.Ped.Common.Extensions
{
    /// <summary>
    /// Extensions of <see cref="DependencyObject"/>
    /// </summary>
    public static class DependencyObjectExtension
    {
        /// <summary>
        /// Find the ancestor of a specific <see cref="DependencyObject"/>. The ancestor type is
        /// defined.
        /// </summary>
        /// <typeparam name="T">Type of the ancestor we are looking for</typeparam>
        /// <param name="obj">Object which ancestor we are looking for</param>
        /// <returns>Object that is an ancestor of a given object, having the specific <see cref="Type"/></returns>
        public static T FindAncestor<T>(this DependencyObject obj) where T : DependencyObject
        {
            return DependencyObjectHelper.FindAncestor<T>(obj);
        }
    }
}
